package fhp.hlhj.giantfold.presenter

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.interfaces.IMain
import fhp.hlhj.giantfold.interfaces.ShowLoadingListener
import fhp.hlhj.giantfold.javaBean.ErroBean
import fhp.hlhj.giantfold.javaBean.GetKeyBean
import fhp.hlhj.giantfold.module.MainModule

/**
 * author: FHP
 * data: on 2017\12\4 0004 11:16
 * E-Mail: 103945089@qq.com
 */
class MainPresenter(private val iMain: IMain) : MainModule.IsOverListener {
    private val mainModule:MainModule= MainModule()
    fun getTaoKeToken(){
        mainModule.getToken(this,object : ShowLoadingListener {
            override fun showloading() {
                iMain.showLoaing()
            }
        })
    }

    /**
     * 获取三方key
     */
    fun getKey(params: HttpParams){
        mainModule.getKey(params,this)
    }

    override fun over(token: String) {
        iMain.getToken(token)
    }
    override fun keyOver(getKeyBean: GetKeyBean) {
        iMain.getKey(getKeyBean)
    }

    override fun error(erroBean: ErroBean) {
        iMain.onError(erroBean)
    }

}